Skip to content

Refactor naming, headers, and include dependencies#16

Merged
gdtknight merged 15 commits intomainfrom
develop
Mar 27, 2026
Merged

Refactor naming, headers, and include dependencies#16
gdtknight merged 15 commits intomainfrom
develop

Conversation

@gdtknight
Copy link
Copy Markdown
Owner

@gdtknight gdtknight commented Mar 27, 2026

Description

모듈/함수 네이밍 일관성 개선, 헤더 정리, include 의존성 최소화 등 전반적인 리팩토링

Related Issue

없음

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Build/CI improvement

Changes

모듈/파일 리네임

  • bvh_vis/bvh_debug/ (bvh_vis_ 접두사 → bvhd_)
  • minirt.hscene.h (헤더 역할에 맞는 이름)
  • mlx_context.hdisplay.h (모듈 디렉토리명과 일치)

함수 리네임

  • scene_build_bvhbuild_scene_bvh (동사-우선 컨벤션)
  • intersect_object_new_new 접미사 제거 (마이그레이션 잔재)
  • is_in_shadowshadow_is_occluded (모듈 접두사 통일)
  • HUD 함수에 hud_ 접두사 추가 (render_camera_fovhud_render_camera_fov 등)
  • ft_strcpy/ft_itoa_bufhud_strcpy/hud_itoa_buf (HUD 전용 헬퍼)

파서 리팩토링

  • 불필요한 NULL 가드 제거 (내부 함수 호출 규약 보장)
  • dispatch_elementdispatch_line 등 함수명 명확화
  • 에러 코드 정확도 개선 (PARSE_ERR_FORMATPARSE_ERR_OVERFLOW)
  • 소규모 파일 병합: parse_token.cparser_utils.c, parse_number_utils.cparse_number.c, parse_error_msg.cparse_error.c

코드 단순화

  • scene_flags.c 제거: 비트 연산 래퍼 인라인화
  • object_list_grow() static 전환
  • timer_start/timer_elapsed_ms 제거, timer_elapsed_usutils.h로 이동
  • debounce_timer_start/reset/stop 래퍼 제거, 직접 대입
  • 프로토타입 적절한 헤더로 이동 (render pipeline → render.h, event callbacks → display.h)

include 의존성 최소화

  • scene.h에서 불필요한 transitive include 제거 (libft.h, error.h, ray.h 등)
  • display.h에 mlx.h include 추가 (소스 파일 중복 제거)
  • hud_internal.h: scene.h 대신 vec3.h + forward declaration으로 경량화
  • 50개 소스 파일에서 중복 include 제거

Testing

Test Environment

  • OS: Ubuntu (Linux 6.8.0)
  • Compiler: cc (gcc)

Test Steps

  1. make re 전체 리빌드 성공 확인
  2. norminette src/ includes/ 전체 통과 확인
  3. 기존 테스트 씬 파일로 동작 확인

Test Results

  • All existing tests pass
  • New tests added and passing
  • Manual testing completed
  • Norminette check passed
  • No memory leaks (valgrind/leaks)

Screenshots

해당 없음

Checklist

  • Code follows project style guidelines (norminette)
  • Self-review of code completed
  • Comments added for complex logic
  • Documentation updated (if needed)
  • No new warnings generated
  • Tests added for new functionality
  • All tests passing locally
  • Branch is up to date with base branch
  • Commit messages follow conventional format
  • No sensitive data included

Constitution Compliance

  • 42 Norminette compliance verified
  • Code readability prioritized
  • Unit tests created and passing
  • Documentation updated (English + Korean if applicable)
  • Build verification completed
  • Git branch strategy followed
  • Logs stored in logs/ directory

Performance Impact

  • No performance impact
  • Performance improved
  • Performance decreased (justified below)

Additional Notes

동작 변경 없는 순수 리팩토링입니다. 15개 커밋으로 관심사별 분리하여 리뷰 용이성을 높였습니다.

🤖 Generated with Claude Code

gdtknight and others added 14 commits March 27, 2026 17:24
- Remove redundant NULL guards in internal functions
  (skip_whitespace, at_line_end, line_reader_next, line_reader_init,
  error_context_init)
- Rename dispatch functions for clarity: dispatch_element → dispatch_line,
  dispatch_elements → dispatch_scene_element, dispatch_objects →
  dispatch_object
- Use precise error codes: PARSE_ERR_FORMAT → PARSE_ERR_OVERFLOW for
  allocation failures (object_list_add, bump_path, line malloc)
- Replace io_error boolean with error field carrying specific
  t_parse_result codes (PARSE_ERR_IO, PARSE_ERR_OVERFLOW)
- Remove error_context_set_line/error_context_set_element wrappers,
  assign fields directly
- Simplify line_reader_init to void (cannot fail)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- bvh_vis/ → bvh_debug/, bvh_vis.h → bvh_debug.h
- All bvh_vis_ prefixes → bvhd_ (shorter, consistent)
- bvh_visualize() → bvhd_run()
- Update Makefile SRCS and includes in main.c, render_loop.c

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Align with verb-first naming convention used elsewhere.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- intersect_object_new → intersect_object
- intersect_cylinder_new → intersect_cylinder
- intersect_cone_new → intersect_cone

The _new suffix was a migration artifact; the old versions no longer
exist, so the suffix adds no value.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Align with module-prefixed naming convention (shadow_*).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- format_and_print_vec3 → hud_print_vec3
- render_camera_fov → hud_render_camera_fov
- render_light_bright → hud_render_light_bright
- render_object_entry → hud_render_object_entry
- keyguide_render_content2 → keyguide_render_objects_section (static)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Merge single-purpose files back into their parent modules to reduce
file count and improve locality:
- parse_token.c → parser_utils.c (skip_whitespace, at_line_end)
- parse_number_utils.c → parse_number.c (parse_int_part, parse_frac_part)
- parse_error_msg.c → parse_error.c (error_write_int, get_error_message)
- Replace parse_is_digit() with libft's ft_isdigit()

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove scene_flags.c: scene_has_ambient, scene_has_camera,
  scene_set_flag, scene_clear_flag were trivial wrappers around
  bitwise ops — inline them at call sites
- Make object_list_grow() static (only called within object_list.c)
- Remove exported prototypes from minirt.h

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move timer_elapsed_us declaration from metrics.h to utils.h
- Remove timer_start (callers use gettimeofday directly)
- Remove timer_elapsed_ms (unused)
- metrics_frame.c: call gettimeofday directly

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove debounce_timer_start/reset/stop — these were one-line
  wrappers around gettimeofday/is_active assignments
- Inline timer operations directly at call sites in render_debounce.c
- Use timer_elapsed_us from utils.h in debounce_timer_expired and
  debounce_check_preview_throttle

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- render_scene_to_buffer, create_camera_ray, trace_ray:
  minirt.h → render.h (render pipeline belongs in render module)
- close_window, handle_key, handle_expose:
  render.h/input.h → mlx_context.h (MLX event callbacks belong
  with MLX context)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The header defines scene, camera, light, and object types — scene.h
better reflects its actual content. Update all 40 source files that
included minirt.h.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Align header name with its module directory (src/display/).
Update include guard and all source files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
These are HUD-specific format helpers, not libft extensions — use the
hud_ prefix. Move declarations from hud.h (public) to hud_internal.h
(module-internal only).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gdtknight gdtknight changed the title Refactor parser error handling and naming Refactor and rename across parser, scene, render, and display modules Mar 27, 2026
@gdtknight gdtknight self-assigned this Mar 27, 2026
- scene.h: remove transitive includes (libft.h, error.h, ray.h,
  unistd.h, fcntl.h, stdbool.h) — consumers include what they need
- display.h: add mlx.h include (was duplicated in each display/*.c)
- render.h: replace mlx.h with ray.h (mlx.h now comes via display.h)
- hud_internal.h: replace scene.h with vec3.h + forward declaration
  of t_render to reduce coupling
- Remove redundant includes from 50 source files (scene.h, render.h,
  mlx.h where already provided transitively by module headers)
- Add explicit libft.h/error.h where needed after scene.h cleanup

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gdtknight gdtknight changed the title Refactor and rename across parser, scene, render, and display modules Refactor naming, headers, and include dependencies Mar 27, 2026
@gdtknight gdtknight merged commit edec7c1 into main Mar 27, 2026
20 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant